package org.example;

import com.ruoyi.RuoYiApplication;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Configuration
@ComponentScan(value = "org.example.**")
@MapperScan("org.example.**.mapper")
public class CaiXiaoApplication {
    public final static Logger log = LoggerFactory.getLogger(CaiXiaoApplication.class);

    public static void main(String[] args)  throws UnknownHostException{

        ConfigurableApplicationContext application = SpringApplication.run(new Class[]{
                RuoYiApplication.class,
                CaiXiaoApplication.class
        }, args);

        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");

        log.info("\n----------------------------------------------------------\n\t" +
                "Application  is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "\n\t" +
                "----------------------------------------------------------");
    }
}
